﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Rescue_of_the_Dwarvenzombies.SceneObjects.GameObjects;

namespace Rescue_of_the_Dwarvenzombies.SceneObjects.GUIObjects
{
    internal class GUIHandler
    {
        private TimeBar _timebar;
        private ScoreBar _scoreBar;
        private List<GameObject> _guiObjects;
        /// <summary>
        /// Initializes a new instance of the GUIHandler class.
        /// </summary>
        /// <param name="game">The game.</param>
        public GUIHandler(Game game)
        {
            _timebar = new TimeBar(game);
            _scoreBar = new ScoreBar(game);
            _guiObjects = new List<GameObject>();
            _guiObjects.Add(_timebar);
            _guiObjects.Add(_scoreBar);
        }

        /// <summary>
        /// Updates the GUIobjects
        /// </summary>
        /// <param name="gameTime"></param>
        internal void Update(GameTime gameTime)
        {
            _timebar.Update(gameTime);
            _scoreBar.Update(gameTime);
        }

        /// <summary>
        /// Reduce time of timebar equal to damage taken
        /// </summary>
        /// <param name="damage"></param>
        internal void ReduceTime(float damage)
        {
            _timebar.TakeDamage(damage);
        }

        /// <summary>
        /// Increase time of timebar from potions
        /// </summary>
        /// <param name="time"></param>
        internal void IncreaseTime(float time)
        {
            _timebar.AddTime(time);
        }

        /// <summary>
        /// Increases the score.
        /// </summary>
        /// <param name="score">The score.</param>
        internal void IncreaseScore(float score)
        {
            _scoreBar.TotalScore += score;
        }

        public List<GameObject> GetGUIObjects()
        {
            return _guiObjects;
        }

        /// <summary>
        /// Check if timebar is depleted
        /// </summary>
        /// <returns></returns>
        internal bool IsTimeLeft()
        {
            return _timebar.TimeLeft > 0;
        }
    }
}